<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>猜数字</title>
</head>
<body>
        <script>
            var i = 0;
            var z = Math.floor(Math.random()*20);
            console.log(z);
            while (i<20){
                var inputV = prompt('请输入一个数');
                if (inputV == z) {
                    alert('你猜对了')
                    break;
                }
                console.log(i);
                i++
            }


            var z = 10;
            while (true){
                var inputV = prompt('请输入一个数');
                if (inputV == z){
                    alert('对了');
                    break;
                }
            }
        </script>
</body>
</html>